<template>
  <div class="cu-common-layout">
    <div class="cu-common-layout-center">
      <el-row class="cu-common-search-box" :gutter="16">
        <el-form @submit.native.prevent>
          <el-col :span="6">
            <el-form-item label="师训名称">
              <el-input v-model="query.title" placeholder="师训名称" clearable />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="证书模版" prop="certificateTemplate">
              <el-select v-model="query.certificateTemplate" placeholder="请选择" required :style="{ width: '100%' }" filterable lastLevel>
                <el-option-group v-for="group in certificateTemplateOptions" :key="group.id" :label="group.fullName">
                  <el-option v-for="item in group.children" :key="item.id" :label="item.fullName" :value="item.enCode"></el-option>
                </el-option-group>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="校区品牌">
              <el-select v-model="query.brand" placeholder="校区品牌" filterable required :style="{ width: '100%' }">
                <el-option :key="item.id" :label="item.fullName" :value="item.enCode" v-for="item in brandOptions" />
              </el-select>
            </el-form-item>
          </el-col>
          <template v-if="showAll">
            <el-col :span="6">
              <el-form-item label="校区状态" prop="">
                <el-select v-model="query.campusStatus" placeholder="请选择校区状态" clearable multiple>
                  <el-option v-for="(item, index) in statusOptions" :key="item.id" :label="item.fullName" :value="item.enCode" />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="校区阶段">
                <el-select v-model="query.campusLevel" placeholder="请选择校区阶段" clearable multiple>
                  <el-option :key="item.id" :label="item.fullName" :value="item.enCode" v-for="item in levelOptions" />
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="6">
              <el-form-item label="管理区域">
                <el-select v-model="query.company" placeholder="请选择" clearable required :style="{ width: '100%' }">
                  <el-option v-for="(item, index) in companyOptions" :key="index" :label="item.fullName" :value="item.enCode"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="行政区域">
                <custom-address v-model="query.provinceId" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="师训时间">
                <el-date-picker v-model="query.registStartDate" type="daterange" :picker-options="pickerOptions" value-format="yyyy-MM-dd" start-placeholder="开始日期" end-placeholder="结束日期" clearable :editable="false"></el-date-picker>
              </el-form-item>
            </el-col>
          </template>
          <el-col :span="6">
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" @click="search()" native-type="submit">{{ $t('common.search') }}</el-button>
              <el-button type="text" icon="el-icon-arrow-down" @click="showAll = true" v-if="!showAll">展开</el-button>
              <el-button type="text" icon="el-icon-arrow-up" @click="showAll = false" v-else>收起</el-button>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div class="cu-common-layout-main cu-flex-main">
        <div class="cu-common-head">
          <div>
            <!-- <el-button type="primary" icon="el-icon-plus" @click="addOrUpdateHandle()" v-has="'btn_add'">新增</el-button> -->
            <el-button type="text" icon="el-icon-download" @click="exportData()">导出</el-button>
          </div>
          <div class="cu-common-head-right">
            <el-tooltip effect="dark" content="刷新" placement="top">
              <el-link icon="icon-ym icon-ym-Refresh cu-common-head-icon" :underline="false" @click="reset()" />
            </el-tooltip>
            <screenfull isContainer />
          </div>
        </div>
        <custom-table v-loading="listLoading" :data="list">
          <el-table-column prop="code" label="校区编码" align="center" width="80" />
          <el-table-column prop="shortName" label="校区简称" width="300" align="left" show-overflow-tooltip></el-table-column>
          <el-table-column prop="typeText" label="校区类型" align="left" width="100" show-overflow-tooltip></el-table-column>
          <el-table-column prop="manager" label="校区负责人" align="left" width="110" show-overflow-tooltip></el-table-column>
          <el-table-column prop="managerMobile" label="负责人电话" align="left" width="120" show-overflow-tooltip></el-table-column>
          <el-table-column prop="startDate" label="服务开始时间" width="120" align="left" :formatter="custom.tableDateFormat" show-overflow-tooltip></el-table-column>
          <el-table-column prop="endDate" label="服务结束时间" width="120" align="left" :formatter="custom.tableDateFormat" show-overflow-tooltip></el-table-column>
          <el-table-column prop="status" label="校区状态" align="center" width="80">
            <template slot-scope="scope">
              <el-tag size="mini" v-if="scope.row.status == 'preparation'" key="筹备" type="" effect="dark">
                筹备
              </el-tag>
              <el-tag size="mini" v-if="scope.row.status == 'normal'" key="正常" type="success" effect="dark">
                正常
              </el-tag>
              <el-tag size="mini" v-if="scope.row.status == 'expires'" key="到期" type="info" effect="dark">
                待续费
              </el-tag>
              <el-tag size="mini" v-else-if="scope.row.status == 'suspended'" key="暂停" type="warning" effect="dark">
                暂停
              </el-tag>
              <el-tag size="mini" v-else-if="scope.row.status == 'close'" key="闭校" type="danger" effect="dark">
                闭校
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="brandText" label="校区品牌" align="center" width="80" />
          <el-table-column prop="province" label="省份" align="center" width="200" />
          <el-table-column prop="company" label="所属区域" align="center" width="120" />
          <el-table-column prop="levelText" label="校区阶段" align="center" width="80" />
        </custom-table>
        <pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData" />
        <export-box v-if="exportBoxVisible" ref="ExportBox" @download="download" />
      </div>
    </div>
  </div>
</template>
<script>
export { default } from './index.js'
</script>
<style lang="scss">
.my-body-container {
  width: 100%;
  overflow-y: auto;
}
.static {
  .el-card {
    height: 100%;
  }
}
</style>
